/*
RGBColor.h
Written by Matthew Fisher

Generic 32-bit RGBA triplet structure.
*/

struct RGBColor
{
    RGBColor() {}
    RGBColor(BYTE _r, BYTE _g, BYTE _b)
    {
        r = _r;
        g = _g;
        b = _b;
    }
    RGBColor(BYTE _r, BYTE _g, BYTE _b, BYTE _a)
    {
        r = _r;
        g = _g;
        b = _b;
        a = _a;
    }

    inline static int DistL1(RGBColor a, RGBColor b)
    {
        return Math::AbsInt(int(a.r) - int(b.r)) +
               Math::AbsInt(int(a.g) - int(b.g)) +
               Math::AbsInt(int(a.b) - int(b.b));
    }
    inline static int DistL2(RGBColor a, RGBColor b)
    {
        int DiffR = int(a.r) - int(b.r);
        int DiffG = int(a.g) - int(b.g);
        int DiffB = int(a.b) - int(b.b);
        return DiffR * DiffR + DiffG * DiffG + DiffB * DiffB;
    }

    inline static RGBColor RandomColor()
    {
        return RGBColor(rand() & 255, rand() & 255, rand() & 255);
    }

    inline RGBColor Inverse()
    {
        return RGBColor(255 - r, 255 - g, 255 - b, 255 - a);
    }

    static RGBColor Interpolate(RGBColor LowColor, RGBColor HighColor, float s);
    static const RGBColor White;
    static const RGBColor Red;
    static const RGBColor Green;
    static const RGBColor Gray;
    static const RGBColor Blue;
    static const RGBColor Yellow;
    static const RGBColor Orange;
    static const RGBColor Magenta;
    static const RGBColor Black;
    static const RGBColor Cyan;
    static const RGBColor Purple;

    BYTE r, g, b, a;
};

inline bool operator == (RGBColor a, RGBColor b)
{
    return (a.r == b.r && a.g == b.g && a.b == b.b);
}

inline bool operator != (RGBColor a, RGBColor b)
{
    return (a.r != b.r || a.g != b.g || a.b != b.b);
}